clear 

cd "__YOUR PATH HERE___"

use "gwf/GWF_AllPoliticalRegimes.dta", clear

rename cowcode ccode

merge 1:1 ccode year using "svolik/institutions in dictatorships, 1946-2008.dta"


gen democracy = .
replace democracy = 1 if gwf_nonautocracy == "democracy"
replace democracy = 0 if gwf_regimetype != "NA"

gen dictatorship = .
replace dictatorship = 1 if gwf_regimetype != "NA"
replace dictatorship = 0 if democracy == 1

gen el_auth = .
replace el_auth = 1 if (executive == "elected by less than 75%" | executive == "elected by more than 75%" | ///
						legislative == "largest party controls more than 75%" | legislative == "largest party controls less than 75% of seats")
replace el_auth = 0 if el_auth != 1 & dictatorship == 1
replace el_auth = 0 if democracy == 1

gen nonel_auth = .
replace nonel_auth = 1 if el_auth == 0
replace nonel_auth = 0 if el_auth == 1
replace nonel_auth = 0 if democracy == 1


preserve

collapse (mean) el_auth nonel_auth democracy, by(year)
keep if year < 2009


tsset year
tsline el_auth nonel_auth democracy, legend(off) text(.55 2015 "Democratic") ///
		text(.3 2012 "Electoral Authoritarian", color(red)) ///
		text(.15 2012 "Closed Authoritarian", color(blue)) ///
		ytitle(Proportion of all Consolidated Regimes) xtitle(Year)

graph export fig1.eps, replace

restore
